package cn.meng.base.service;

import cn.meng.base.mapper.EmployeeMapper;
import cn.meng.base.vo.EmployeeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 员工信息service实现类
 * @author 万梦辉
 */
@Service
public class EmployeeServiceImpl implements EmployeeService{

    @Autowired
    EmployeeMapper employeeMapper;

    @Override
    @CachePut(value = "Employee",key = "#employee")
    public Integer insertEmployee(EmployeeVo employee) {
        return employeeMapper.insertEmployee(employee);
    }

    @Override
    @CachePut(value = "Employee",key = "#employees")
    public Integer batchInsertEmployee(List<EmployeeVo> employees) {
        return employeeMapper.batchInsertEmployee(employees);
    }

    @Override
    @CachePut(value = "Employee",key = "#pk_employee")
    public Integer updateEmployeeNameByPk(String pk_employee, String name) {
        return employeeMapper.updateEmployeeNameByPk(pk_employee,name);
    }

    @Override
    @Cacheable(value = "Employee",key = "#pk_employee")
    public EmployeeVo selectEmployeeByPK(String pk_employee) {
        return employeeMapper.selectEmployeeByPK(pk_employee);
    }
}
